//
//  YZMStockSellHeader.m
//  YZMicroStock
//
//  Created by wangminhong on 16/4/26.
//  Copyright © 2016年 cqjr. All rights reserved.
//

#import "YZMStockSellHeader.h"
#import "NSNumber+Utils.h"

@interface YZMStockSellHeader()

@property (nonatomic, strong) UILabel *detailLabel;

@end

@implementation YZMStockSellHeader

- (instancetype)initWithReuseIdentifier:(nullable NSString *)reuseIdentifier{
    
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.contentView.backgroundColor = [YZMAppStyle colorForString:@"#E2E2E2"];
        self.detailLabel = [YZMAppStyle labelWithFont:[YZMAppStyle smallSizeFont] andColor:[YZMAppStyle colorForGrayText]];
        self.detailLabel.numberOfLines = 0;
        [self addSubview:self.detailLabel];
        [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(15);
            make.right.equalTo(self).offset(-15);
            make.centerY.equalTo(self).offset(2);
        }];
    }
    
    return self;
}

- (void)setTotalMoney:(double)totalMoney andExpireMoney:(double)expireMoney{
    
    if ([@(expireMoney) isEqualWithDouble:0.0]) {
        
        self.detailLabel.text = [NSString stringWithFormat:@"递延费：%@元\n请保持余额充足，若截至当日14:50余额不足，视为终止合约，将点卖策略。", @(totalMoney).p02fString];
    }else{
        self.detailLabel.text = [NSString stringWithFormat:@"递延费：%@元(含逾期金额%@元)\n请保持余额充足，若截至当日14:50余额不足，视为终止合约，将点卖策略。", @(totalMoney).p02fString, @(expireMoney).p02fString];
    }
    
}

+ (CGFloat)getHeightOfSelfTotalMoney:(double)totalMoney andExpireMoney:(double)expireMoney {
    
    UILabel *label = [UILabel new];
    label.font = [YZMAppStyle smallSizeFont];
    label.numberOfLines = 0;
    if ([@(expireMoney) isEqualWithDouble:0.0]) {
        
        label.text = [NSString stringWithFormat:@"递延费：%@元\n请保持余额充足，若截至当日14:50余额不足，视为终止合约，将点卖策略。", @(totalMoney).p02fString];
    }else{
        label.text = [NSString stringWithFormat:@"递延费：%@元(含逾期金额%@元)\n请保持余额充足，若截至当日14:50余额不足，视为终止合约，将点卖策略。", @(totalMoney).p02fString, @(expireMoney).p02fString];
    }
    return [label systemLayoutSizeFittingSize:CGSizeMake([UIScreen mainScreen].bounds.size.width - 30, 80)].height+10;
}

@end
